<%-- 
    Document   : edit
    Created on : Apr 22, 2010, 7:47:50 PM
    Author     : Caesar
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<f:view locale="#{locale.locale}">
    <f:loadBundle basename="ru.ssau.berlin.jsf.i18n.Messages" var="bundle"/>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title><h:outputText value="#{bundle.ssau_manage_system} :: #{bundle.group}"/></title>
        </head>
        <body>
            <small>
                <h:form>
                    <h:commandLink action="#{locale.setLocale}" value="en">
                        <f:param name="locale" value="en"/>
                    </h:commandLink> |
                    <h:commandLink action="#{locale.setLocale}" value="ru">
                        <f:param name="locale" value="ru"/>
                    </h:commandLink>
                </h:form>
            </small>
            <h1><h:outputText value="#{bundle.group}"/></h1>
            <h:form>
                <h:messages layout="table"/>
                <h:panelGrid columns="2">
                    <h:outputText value="#{bundle.id}:"/>
                    <h:outputText value="#{group.group.id}"/>
                    <h:outputLabel for="name" value="#{bundle.name}:"/>
                    <h:inputText id="name" value="#{group.group.name}"
                                 readonly="#{group.readonly}"/>
                    <h:outputLabel for="type" value="#{bundle.type}:"/>
                    <h:selectOneMenu id = "type"
                                     value="#{group.group.type}"
                                     readonly="#{group.readonly}"
                                     rendered="#{not empty group.types}"
                                     converter="berlin.GroupTypeConverter">
                        <f:selectItems value="#{group.items}"/>
                    </h:selectOneMenu>
                </h:panelGrid>
                <h:dataTable value="#{group.group.parameters}" var="item"
                             rendered="#{not empty group.group.parameters}">
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.parameter}"/>
                        </f:facet>
                        <h:outputText value="#{item.attribute.name}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.value}"/>
                        </f:facet>
                        <h:inputText value="#{item.parameterValue}"
                                     readonly="#{group.readonly}">
                            <f:validator validatorId="berlin.AttributeValidator"/>
                            <f:attribute name="attribute_type" value="#{item.attribute.type}"/>
                        </h:inputText>
                    </h:column>
                    <h:column rendered="#{not group.readonly}">
                        <f:facet name="header">
                            <h:outputText value="#{bundle.actions}"/>
                        </f:facet>
                        <h:commandLink actionListener="#{group.deleteParameter}"
                                       action="#{navigator.stayHere}"
                                       value="#{bundle.delete}">
                            <f:attribute name="id_param" value="#{item.id}"/>
                        </h:commandLink>
                    </h:column>
                </h:dataTable>
                <h:commandButton action="#{group.persistGroup}"
                                 value="#{bundle.save}" rendered="#{not group.readonly}">
                    <f:param name="id_param" value="#{group.group.id}"/>
                </h:commandButton>
                <h:commandButton actionListener="#{group.deleteGroup}"
                                 value="#{bundle.delete}" action="#{group.showAllGroups}"
                                 rendered="#{group.group.id != null}">
                    <f:attribute name="id_param" value="#{group.group.id}"/>
                </h:commandButton> <br/>
                <h:selectOneMenu value="#{group.attr}" id="attribute"
                                 rendered="#{not group.readonly
                                             and group.group.id != null
                                             and not empty group.attrItems}"
                                 converter="berlin.GroupAttributeConverter">
                    <f:selectItems value="#{group.attrItems}"/>
                </h:selectOneMenu>
                <h:inputText value="#{group.value}"
                             rendered="#{not group.readonly
                                         and group.group.id != null
                                         and not empty group.attrItems}">
                    <f:validator validatorId="berlin.GroupAttributeValidator"/>
                </h:inputText>
                <h:commandButton action="#{group.addParameter}"
                                 value="#{bundle.add} #{bundle.parameter}"
                                 rendered="#{not group.readonly
                                             and group.group.id != null
                                             and not empty group.attrItems}">
                    <f:param name="id_param" value="#{group.group.id}"/>
                </h:commandButton>
                <h2><h:outputText value="#{bundle.persons}"/></h2>
                <h:dataTable value="#{group.group.persons}" var="item"
                             rendered="#{not empty group.group.persons}"
                             border="1">
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.id}"/>
                        </f:facet>
                        <h:commandLink action="#{person.showPerson}" value="#{item.id}">
                            <f:param name="id_param" value="#{item.id}"/>
                        </h:commandLink>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.name}"/>
                        </f:facet>
                        <h:outputText value="#{item.name}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.type}"/>
                        </f:facet>
                        <h:outputText value="#{item.type}"/>
                    </h:column>
                    <h:column rendered="#{not group.readonly}">
                        <f:facet name="header">
                            <h:outputText value="#{bundle.actions}"/>
                        </f:facet>
                        <h:commandLink action="#{group.leavePerson}" value="#{bundle.exclude}">
                            <f:param name="id_param" value="#{item.id}"/>
                        </h:commandLink>
                    </h:column>
                </h:dataTable>
                <h:selectOneMenu value="#{group.person}"
                                 rendered="#{not group.readonly
                                             and group.group.id != null
                                             and not empty group.personItems}"
                                 converter="berlin.PersonConverter">
                    <f:selectItems value="#{group.personItems}"/>
                </h:selectOneMenu>
                <h:commandButton action="#{navigator.stayHere}" value="#{bundle.join}"
                                 actionListener="#{group.joinPerson}"
                                 rendered="#{not group.readonly
                                             and group.group.id != null
                                             and not empty group.personItems}"/>
                <h2><h:outputText value="#{bundle.events}"/></h2>
                <h:dataTable value="#{group.group.events}" var="item"
                             rendered="#{not empty group.group.events}"
                             border="1">
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.id}"/>
                        </f:facet>
                        <h:commandLink action="#{event.showEvent}" value="#{item.id}">
                            <f:param name="id_param" value="#{item.id}"/>
                        </h:commandLink>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.name}"/>
                        </f:facet>
                        <h:outputText value="#{item.name}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.type}"/>
                        </f:facet>
                        <h:outputText value="#{item.type}"/>
                    </h:column>
                    <h:column rendered="#{not group.readonly}">
                        <f:facet name="header">
                            <h:outputText value="#{bundle.actions}"/>
                        </f:facet>
                        <h:commandLink action="#{group.leaveEvent}" value="#{bundle.leave}">
                            <f:param name="id_param" value="#{item.id}"/>
                        </h:commandLink>
                    </h:column>
                </h:dataTable>
                <h:selectOneMenu value="#{group.event}"
                                 rendered="#{not group.readonly
                                             and group.group.id != null
                                             and not empty group.eventItems}"
                                 converter="berlin.EventConverter">
                    <f:selectItems value="#{group.eventItems}"/>
                </h:selectOneMenu>
                <h:commandButton action="#{navigator.stayHere}" value="#{bundle.join}"
                                 actionListener="#{group.joinEvent}"
                                 rendered="#{not group.readonly
                                             and group.group.id != null
                                             and not empty group.eventItems}"/>
            </h:form>
            <h:form>
                <h2><h:outputText value="#{bundle.navigation}"/></h2>
                <h:commandLink action="#{group.showAllGroups}" value="#{bundle.groups_list}"/> <br/>
                <h:commandLink action="#{navigator.goToMainPage}" value="#{bundle.home}"/>
            </h:form>
        </body>
    </html>
</f:view>
